//导入要操作的表
const CourseModel = require('../modules/CourseModel')

module.exports = {

    //banner
    get_bannerlist: async function (req, res) {
        let resultArr = [];
        await CourseModel.bannerlist(req)
            .then(
                res => {
                    resultArr = res;
                }
            )
        res.send(resultArr)
    },

    //新上好课
    get_newcourse: async function (req, res) {
        let resultArr = [];
        await CourseModel.newcourse(req)
            .then(
                res => {
                    resultArr = res;
                }
            )
        res.send(resultArr)
    },

    //前端课程
    get_frontendcourse: async function (req, res) {
        let resultArr = [];
        await CourseModel.frontendcourse(req)
            .then(
                res => {
                    resultArr = res;
                }
            )
        res.send(resultArr)
    },

    //后端课程
    get_rearendcourse: async function (req, res) {
        let resultArr = [];
        await CourseModel.rearendcourse(req)
            .then(
                res => {
                    resultArr = res;
                }
            )
        res.send(resultArr)
    },

    //学习路线
    get_linecourse: async function (req, res) {
        let resultArr = [];
        await CourseModel.linecourse(req)
            .then(
                res => {
                    resultArr = res;
                }
            )
        res.send(resultArr)
    },

    //初级课程
    get_primary: async function (req, res) {
        let resultArr = [];
        await CourseModel.primary(req)
            .then(
                res => {
                    resultArr = res;
                }
            )
        res.send(resultArr)
    },

    // 中级课程
    get_middlelevel: async function (req, res) {
        let resultArr = [];
        await CourseModel.middlelevel(req)
            .then(
                res => {
                    resultArr = res;
                }
            )
        res.send(resultArr)
    },
    // 高级课程
    get_highranking: async function (req, res) {
        let resultArr = [];
        await CourseModel.highranking(req)
            .then(
                res => {
                    resultArr = res;
                }
            )
        res.send(resultArr)
    },
    //存课程id和用户id至study-myclass表
    post_addcourseselection: async function (req, res) {
        addmyclassResult = await CourseModel.addcourseselection(req.body.courseid, req.body.userid)
        res.send(addmyclassResult)
    },
    //拿用户id获取对应用户 => 我的课程 
    post_courseselection: async function (req, res) {
        userclassResult = await CourseModel.courseselection(req.body.userid)
        res.send(userclassResult)
    },

    //我的课程
    post_mycourse: async function (req, res) {
        mycourseResult = await CourseModel.mycourse(req.body.userid)
        res.send(mycourseResult)
    },

   

    //我的作业 mywork
    post_mywork: async function (req, res) {
        myworkResult = await CourseModel.mywork(req.body.userid)
        res.send(myworkResult)
    },

}